package com.example.consumer;


import com.example.User;
import com.example.UserService;
import framework.annotation.XReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/test")
public class Test {

    @XReference
    private UserService userService;

    @GetMapping("/listUser")
    public void listUser() {
        List<User> users = userService.listUser();
        if (users == null) {
            System.out.println("users is null");
            return;
        }
        for (User user : users) {
            System.out.println(user.toString());
        }
    }

    @GetMapping("/addUser")
    public void addUser() {
        String string = userService.addUser(new User("guochuang", "kk1"));
        System.out.println(string);
    }
}
